package com.wtwd.campus.send;

import com.wtwd.campus.common.Constants;
import com.wtwd.campus.entity.Command;
import com.wtwd.campus.entity.MqLockDevice;
import com.wtwd.campus.entity.MqMessage;

/**
 * @author mjy
 * @date 2022/12/29
 * @description
 */
public class SetLockDevice implements Sender {


    @Override
    public Command dealMessage(MqMessage mqMessage) {
        MqLockDevice lockDevice = (MqLockDevice) mqMessage.getObject();
        String imei = lockDevice.getImei();
        int flag = lockDevice.getFlag();
        String commandNumber = lockDevice.getCommandNumber();
        String iccid = lockDevice.getIccid();
        String content = "*".concat(Constants.MANUFACTURER_NAME).concat(",").concat(imei).concat(",").
                concat(Constants.LOCK_DEVICE).concat(",").concat(commandNumber).concat(",").concat(String.valueOf(flag))
                .concat(",").concat(iccid).concat("#");
        Command command = new Command();
        command.setImei(imei);
        command.setContent(content);
        command.setCmd(Constants.LOCK_DEVICE);
        command.setStatus(Constants.COMMAND_NEED_SAVE);
        command.setCommandNumber(commandNumber);
        return command;
    }
}
